#include "AirConditionTerminal_YL.h"

CAirConditionTerminal_YL::CAirConditionTerminal_YL()
{

}

CAirConditionTerminal_YL::~CAirConditionTerminal_YL()
{

}

//函数名称：Open
//函数功能：打开空调
//函数参数：(out)string & Command:输出亿林空调开启命令
//返回值:无
void CAirConditionTerminal_YL::Open(string & Command)
{
    Command = "A210001000000067";
    //cout << Command << endl;
}

//函数名称：Close
//函数功能：关闭空调
//函数参数：(out)string & Command:输出亿林空调关闭空调命令
//返回值:无
void CAirConditionTerminal_YL::Close(string &Command)
{
    Command = "A210000000000017";
    cout << Command << endl;
}

//函数名称：SetTemperature
//函数功能：设置空调温度
//函数参数：(in)const int & value:空调温度值, (out)string & Command:返回亿林空调控制命令
//返回值:无
void CAirConditionTerminal_YL::SetTemperature(const int & value, string & Command)
{
    string Temp, Check;
    int CheckSum;
    CheckSum = (0xA6 + 0x10 + value)^0xA5;
    Tool->IntToString(value, Temp);
    Tool->IntToString(CheckSum, Check);
    Command = "A610000000" + Temp + "00" + Check;
    cout << Command << endl;
}

//函数名称：Set
//函数功能：控制空调
//函数参数：(in)const int & value:设置空调的具体操作, (out)string & Command:返回亿林空调控制命令
//返回值:无
void CAirConditionTerminal_YL::Set(const int & value, string &Command)
{
    switch(value)
    {
        case 'H':  Command = "A310000100000011"; break;
        case 'M':  Command = "A310000200000010"; break;
        case 'L':  Command = "A310000300000013"; break;
        default:
            SetTemperature(value, Command); break;
    }
}

//函数名称：ReturnOk
//函数功能：判断是否成功控制亿林空调控制终端
//函数参数：(in)const string & Message:输入亿林空调控制命令
//返回值:控制成功返回true，否则返回false
bool CAirConditionTerminal_YL::ReturnOK(const string & Message)
{
    if(!Message.length())
        return false;

    string DevHeader(Message.begin() + 4, Message.begin() + 6);
    cout << "DevHeader:" << DevHeader << endl;
    if(DevHeader == "50")
        return true;
    else
        return false;
}

//函数名称：ReturnMessage
//函数功能：
//函数参数：
//返回值:
void CAirConditionTerminal_YL::ReturnMessage()
{

}
